<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\TeamModel;
use App\Models\PlayerModel;
class PlayerController extends Controller
{


    public function playerAdd(){

    	$data=TeamModel::get();

    	return view("admin/playerAdd",['data'=>$data]);
    }


    public function playerCreate(){

     $data=request()->except("_token");

     $res=PlayerModel::create($data);
     if($res){
     	return redirect("admin/playerIndexs");
     }
     
    }


    public function playerIndex($team_id){

    $data=PlayerModel::where(['team_id'=>$team_id])->get();

    return view("admin/playerIndex",['data'=>$data]);
    }


      public function playerIndexs(){

      $data=PlayerModel::join("team","player.team_id","=","team.team_id")->paginate(3);

    return view("admin/playerIndexs",['data'=>$data]);
    }
}
